package com.daiziru.im.server;

import lombok.extern.slf4j.Slf4j;
import org.tio.server.ServerGroupContext;
import org.tio.websocket.server.WsServerStarter;

import java.io.IOException;

/**
 * 作者：無言
 * 时间：2022/12/23 17:37
 * 描述：永无BUG
 * tio服务启动类
 */
@Slf4j
public class ImServerStarter {

    private WsServerStarter starter;
    public ImServerStarter(int port) throws IOException {
        ImWsMsgHandler handle = new ImWsMsgHandler();
        starter = new WsServerStarter(port,handle);
        //获取上下文
        ServerGroupContext serverGroupContext = starter.getServerGroupContext();
        //设置心跳
        serverGroupContext.setHeartbeatTimeout(500000);

    }

    public void start() throws IOException {
        starter.start();
        log.info("tio server start!");
    }
}
